package com.heima.controller.vm_service;


import com.heima.pojo.entity.VendingMachine;
import com.heima.pojo.vo.VmTypeNodeRegionVo;
import com.heima.pojo.vo.PageVo;
import com.heima.service.VendingMachineService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/vm-service/vm")
@Slf4j
public class VendingMachineController {
    @Autowired
    private VendingMachineService vendingMachineService;

    /**
     * 设备搜索
     * @param pageIndex
     * @param pageSize
     * @param innerCode
     * @return
     */
    @GetMapping("/search")
    public PageVo<VmTypeNodeRegionVo> vmPage(
                @RequestParam Integer pageIndex, Integer pageSize, String innerCode){
            PageVo vmPage=  vendingMachineService.getVmPage(pageIndex,pageSize,innerCode);
            return vmPage;
    }

    /**
     * 新增设备
     * @param vendingMachine
     * @return
     */
    @PostMapping
    private Boolean save(@RequestBody VendingMachine vendingMachine){
        return vendingMachineService.save(vendingMachine);

    }

}
